//
//  YQThreeBtnView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQThreeBtnView.h"

@interface YQThreeBtnView ()

/**
 backView
 */
@property (nonatomic,strong) UIView *backView;

@end

@implementation YQThreeBtnView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupThreeBtnView];
    }
    return self;
}

- (void)setupThreeBtnView {
    [self addSubview:self.backView];
//    [self.backView addSubview:self.scanningBtn];
    
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(18));
        make.top.mas_equalTo(FIT(0));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(36), 72));
    }];
    CGFloat btnView_W = (ScreenWidth-FIT(36))/3.0;
    CGFloat btn_W = btnView_W/2.0;
    CGFloat space_w = btn_W/2.0;
    
//    [self.scanningBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(FIT(60));
//        make.centerY.mas_equalTo(self.backView.mas_centerY);
//        make.size.mas_equalTo(CGSizeMake(FIT(60), FIT(60)));
//    }];
    
    
    NSDictionary *titleDic = @{@"1":@"扫一扫",
                               @"2":@"收款",
                               @"3":@"转账"
                               };
    NSDictionary *imgDic = @{@"1":@"scan",
                             @"2":@"code",
                             @"3":@"transfer"};
    for (NSInteger i = 0; i < 3; i++) {
        UIButton *btn = [YQViewFactory buttonWithTitle:[titleDic objectForKey:StringFromLongInt(i+1)] image:YQ_IMAGE([imgDic objectForKey:StringFromLongInt(i+1)]) titleColor:MainBlackColor fontSize:kLittleFont userBold:NO target:self sel:@selector(btnAction:)];
        btn.frame = CGRectMake(space_w + (btn_W+space_w*2)*i, FIT(10), btn_W+10, FIT(60));
        [btn setIconInTopWithSpacing:10];
        btn.tag = 100+i;
        [self.backView addSubview:btn];
    }
    
}

- (UIView *)backView {
    if (!_backView) {
        _backView = [[UIView alloc] init];
        _backView.backgroundColor = WhiteColor;
        _backView.layer.cornerRadius = 8;
        _backView.layer.masksToBounds = NO;
//        UIColorFromRGB(0xeeeee)
        [_backView LX_SetShadowPathWith:[UIColor redColor] shadowOpacity:0.5 shadowRadius:3 shadowSide:LXShadowPathBottom shadowPathWidth:10];
    }
    return _backView;
}

//- (UIButton *)scanningBtn {
//    if (!_scanningBtn) {
//        _scanningBtn = [YQViewFactory buttonWithTitle:@"扫一扫" image:YQ_IMAGE(@"scan") titleColor:MainBlackColor fontSize:kLittleFont userBold:NO target:self sel:@selector(btnAction:)];
//        _scanningBtn.tag = 100;
//        [_scanningBtn layoutButtonWithImageStyle:ZJButtonImageStyleTop imageTitleToSpace:10];
//    }
//    return _scanningBtn;
//}

- (void)btnAction:(UIButton *)sender {
    if (self.block) {
        self.block(sender.tag);
    }
}

@end
